package com.raos.pagehelper2.service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.raos.pagehelper2.dao.SysUserDao;
import com.raos.pagehelper2.model.SysUser;
import com.raos.pagehelper2.utils.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 用户业务操作实现类
 *
 * @author raos
 * @emil 991207823@qq.com
 * @date 2021/09/04 21:31
 */
@Service
public class SysUserServiceImpl implements SysUserService {

    @Autowired
    private SysUserDao sysUserDao;

    @Override
    public List<SysUser> queryAll(Map<String, Object> params) {
        return sysUserDao.queryList(params);
    }

    @Override
    public PageInfo<SysUser> queryListByPage(Map<String, Object> params, PageQuery pageQuery) {
        return PageHelper.startPage(pageQuery.getPage(), pageQuery.getLimit())
                .doSelectPageInfo(() -> this.queryAll(params));
    }

    @Override
    public Page<SysUser> queryListByPage2(Map<String, Object> params, PageQuery pageQuery) {
        return PageHelper.startPage(pageQuery.getPage(), pageQuery.getLimit())
                .doSelectPage(() -> this.queryAll(params));
    }

}
